import request from '../utils/request';
import { DriverPaginatedResponse } from '../types/driver';

// Define the bind account request payload
export interface BindAccountPayload {
  username: string;
  phone: string;
  cardNum: string;
}

// Define the response structure for bind account
export interface BindAccountResponse {
  code: string;
  message: string;
  data: any;
  param: any;
}

/**
 * Fetch driver list data
 * @param params Pagination and filter parameters
 * @returns Paginated driver data
 */
export const getDriverList = async (params?: any): Promise<DriverPaginatedResponse> => {
  return request.get('/api/admin/web/dtu-ftp-message_detail-card/page', { params });
};

/**
 * Bind or create driver account
 * @param payload Account binding information
 * @returns API response
 */
export const bindDriverAccount = async (payload: BindAccountPayload): Promise<BindAccountResponse> => {
  return request.post('/api/admin/web/driver-list/bind-account', payload);
};